package com.kitty.web.controller;

import com.kitty.web.controller.BaseController;
import com.kitty.web.common.AjaxResult;
import com.kitty.web.core.page.TableDataInfo;
import com.kitty.web.domain.Sevenday;
import com.kitty.web.system.sevenday.service.ISevendayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 【请填写功能名称】Controller
 * 
 * @author soul
 * @date 2022-06-13
 */
@Controller
@RequestMapping("/system/sevenday")
public class SevendayController extends BaseController
{
    private String prefix = "system/sevenday";

    @Autowired
    private ISevendayService sevendayService;


    @GetMapping()
    public String sevenday()
    {
        return prefix + "/sevenday";
    }

    /**
     * 查询【请填写功能名称】列表
     */

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Sevenday sevenday)
    {
        startPage();
        List<Sevenday> list = sevendayService.selectSevendayList(sevenday);
        return getDataTable(list);
    }


    /**
     * 新增【请填写功能名称】
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存【请填写功能名称】
     */

    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Sevenday sevenday)
    {
        return toAjax(sevendayService.insertSevenday(sevenday));
    }

    /**
     * 修改【请填写功能名称】
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        Sevenday sevenday = sevendayService.selectSevendayById(id);
        mmap.put("sevenday", sevenday);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */

    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Sevenday sevenday)
    {
        return toAjax(sevendayService.updateSevenday(sevenday));
    }

    /**
     * 删除【请填写功能名称】
     */

    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sevendayService.deleteSevendayByIds(ids));
    }
}
